"Colin's main vimrc
"cagraham@gmail.com
"
"Please re-use anything in this vimrc that you find useful!
"And let me know if you find any other ideas or if you have questions...
"
"Environment variables for this vimrc:
"  $MYTMP      - location of swap files (optional)
"
"  $VIMCFGROOT - defined by $HOME/.vimrc, not exported outside of vim
"  $VIMRC      - defined by $HOME/.vimrc, not exported outside of vim


if ($VIMRC != '')
   "Source options that are set based on the FileType
   source $VIMRC/my_filetype_options.vim

   "Source my grep options and functionality
   source $VIMRC/my_grep.vim

   "Source my diff options and functionality
   source $VIMRC/my_diff.vim

   "Source my GNU Privacy Guard functionality
   source $VIMRC/my_gpg.vim

   "Source my extras (use of GNU miscfiles, etc.)
   source $VIMRC/my_extras.vim

   "Source my plugin options (intellisense plugin, etc.)
   source $VIMRC/my_plugin_options.vim

   "Editing and updating vimrc files:
   map ,v :sp $VIMRC<CR>
   map ,u :call MySourceGvimrc()<CR>:source $HOME/.vimrc<CR>
else
   echoerr "WARNING: \$VIMRC is not defined! Other vimrc files not sourced!"
endif

"Define a function to source gvimrc only if running the GUI
function! MySourceGvimrc()
   if (has("gui_running"))
      source $HOME/.gvimrc
   endif
endfunction

"Things below here should be usable everywhere I vim.

"what's vim without the m?
set nocompatible
"avoid the windows way whenever possible
behave xterm
"make the Backspace key more useful
set backspace=indent,eol,start

"
"Indentation preferences (might be modified for certain file types)
"
"Set up tabs to only be spaces
set ts=3 sw=3 expandtab smarttab
"set softtabstop=3
"Copy indent from the line above when starting a new line
set autoindent

"visual bell (instead of beep), with no screen flashing
set vb t_vb=
"Show when the mode is INSERT or REPLACE or VISUAL, etc.
set showmode
"See some of the command as you type it
set showcmd
"Turn on the ruler (displays current row, column and location in the file)
set ruler

"Immediately show what search pattern will match
set incsearch
"Highlight the current search pattern
set hlsearch
"Remap control-L such that it will also remove the search highlight
"nmap <C-l> :let @/=""<CR>:redraw!<CR>
nmap <C-l> :nohlsearch<CR>:redraw!<CR>

"When adding/subtracting split windows, don't equal size all windows
set noequalalways
"I prefer vertical splits to go on the right instead of the left
set splitright
"Set the minimum window height to zero so we can squish more windows together
set wmh=0
"Control behavior of file-explorer plugin: don't resize explorer window
"after opening a file with 'o'
"let g:explWinSize=5 ---> TBD - not sure what to do with this after-all.
"Map a convenient way to switch between windows (and maximize new window height)
nmap <C-j> <C-W>j<C-W>_
nmap <C-k> <C-W>k<C-W>_

"Wildmenu replaces the status line with the possible cmd line completions
"Use arrow keys to navigate (up and down will navigate directories)
set wildmenu
"Wildmode can be up to four parts, what to do at each stage of <tab>
"when completing the command line.  Default is 'full'.
"set wildmode=longest,list,full

"Map a convenient way to go to the next item in the error-list
nmap <C-n> :cn<CR>
nmap <C-p> :cp<CR>

"Set up a convenient way to switch between buffers or edited files
function! MapNextPrevToBuffers()
   "Could use :bn! and :bp! to switch even when the buffer is modified
   nmap <M-n> :bn<CR>
   nmap <M-p> :bp<CR>
endfunction
command! MapNextPrevToBuffers :call MapNextPrevToBuffers()
function! MapNextPrevToFiles()
   nmap <M-n> :next<CR>
   nmap <M-p> :prev<CR>
endfunction
command! MapNextPrevToFiles :call MapNextPrevToFiles()
"Set a default mapping:
MapNextPrevToFiles

"Map a more convenient and familiar way to go between tabs
nmap <C-tab> :tabnext<CR>
nmap <C-S-tab> :tabprev<CR>

"Remap the jump-to-tag key to show the full list of possible tag matches
"if the match is not unique.
nmap <C-]> g<C-]>
"nmap ,] :unmap <C-]><CR>

"Set up a location for where I want .swp files to go instead of cluttering
"  the directory if each edited file.
if ($MYTMP != '')
   set dir=$MYTMP
endif

"If we end up saving a vim session, also save global variables and local opts
"TBD - commented out for now, as I'm not sure this does good things
"set sessionoptions+=globals,localoptions

"Turn off viminfo, I don't like big brother evidence of my every move.
set viminfo=
"Increase the number of items stored in the history (goes away upon vim exit)
set history=200

